Skip to content

Return empty completion when no handler matches a valid ref#996

Open
jstar0 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/completion-empty-result
Open

Return empty completion when no handler matches a valid ref#996
jstar0 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/completion-empty-result

Conversation

@jstar0
Copy link
Copy Markdown

@jstar0 jstar0 commented Jun 4, 2026

Return empty completion when no handler matches a valid ref

Fixes #991.

Summary

completion/complete currently returns -32602 when a prompt or resource template exists and the requested argument is valid, but no completion handler is registered for that specific reference. In that case there are simply no suggestions to return.

Changes

  • Return an empty completion result for valid prompt/resource-template completion requests when no matching completion handler exists.
  • Keep prompt/resource existence checks and argument validation before the completion-handler lookup, so unknown refs and invalid arguments keep their existing error behavior.
  • Add stateful and stateless integration coverage for prompt and resource-template no-handler completions.

Verification

./mvnw -pl mcp-core -am test
./mvnw -pl mcp-test -am -Dtest=McpCompletionTests,HttpServletStatelessIntegrationTests#testCompletionShouldReturnExpectedSuggestions+testCompletionWithoutMatchingHandlerReturnsEmptyResult+testResourceTemplateCompletionWithoutMatchingHandlerReturnsEmptyResult -Dsurefire.failIfNoSpecifiedTests=false test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

completion/complete throws -32602 when no @McpComplete handler matches the ref; should return EMPTY_COMPLETION_RESULT to match TS/Python SDK

1 participant